
import java.util.Arrays;
import java.util.Scanner;
public class Test {
    //输入：nums = [2,7,11,15], target = 9
    //
    //输出：[0,1]
    //
    //解释：因为 nums[0] + nums[1] == 9 ，返回 [0, 1] 。
    public static int[] search(int[] nums,int target){
        int[] newarray = new int[2];
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = nums.length - 1; j > i; j--) {
                if(nums[i] + nums[j] == target){
                    newarray[0] = i;
                    newarray[1] = j;
                    return newarray;
                }

            }
        }
        return new int[]{-1,-1};

    }
    public static void main(String[] args) {
        int[] nums = {2,7,11,15};
        int target = 9;
        int[] ccc = search(nums,target);
        System.out.println(Arrays.toString(ccc));
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
            while (scanner.hasNextInt()) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                Data data = new Data(x, y);
                System.out.println(data.getX() + data.getY());
            }
        }

    }

    class Data {

        private int x;
        private int y;

        Data(int x, int y) {
            this.x = x;
            this.y = y;
        }

        int getX() {
            return x;
        }

        int getY() {
            return y;
        }

}
